AnnieRoot.gameFW=AnnieRoot.gameFW||{};
gameFW.GameFW=function(){
	var s = this;
	annie.Sprite.call(s);
	/*_a2x_need_start*/s.alertLayer=null;s.gameLayer=null;s.msgLayer=null;s.tipAlertLayer=null;s.uiLayer=null;/*_a2x_need_end*/
	annie.initRes(s,"gameFW","GameFW");
	//your code here
	var gameScene=null,
		gameUi=null,
		gameReadyGo=null,
		gameResult=null,
		gameTip=null,
		gameChooesPrize=null,
		gamePrizeWarmTip=null,
		gameUserMakesureTip=null,
		gameTipAlert=null,
		gameMyPrize=null;
	s.addEventListener(annie.Event.ADD_TO_STAGE, function (e) {
		if (!gameScene) {
			gameScene = new gscene.Gscene();
			s.gameLayer.addChild(gameScene);
		}
		if (!gameUi) {
			gameUi = new ui.Ui();
			s.uiLayer.addChild(gameUi);
		}
	});
	annie.globalDispatcher.addEventListener('addGameUiToStage', function (e) {
		if (!gameUi) {
			gameUi = new ui.Ui();
		}
		if (s.uiLayer.children.length == 0) {
			s.uiLayer.addChild(gameUi);
		}
	});
	/*用户游戏次数不够提示*/
	annie.globalDispatcher.addEventListener('userNotEnoughGameTimes', function (e) {
		s.msgLayer.removeChildAt(0);
		if (annie.isLoadedScene('gtip')) {
			if (!gameTip) {
				gameTip = new gtip.Gtip();
			}
			s.msgLayer.addChild(gameTip);
		} else {
			annie.loadSceneManager('gtip', s.msgLayer);
		}
	});
	/*游戏321准备*/
	annie.globalDispatcher.addEventListener('readyToGameStart', function (e) {
		if (!gameReadyGo) {
			gameReadyGo = new readyGo.ReadyGo();
		}
		gameReadyGo.bringData = 'startGame';
		s.msgLayer.addChild(gameReadyGo);
	});
	/*游戏结果页*/
	annie.globalDispatcher.addEventListener('gameOver', function (e) {
		s.msgLayer.removeChildAt(0);
		if (annie.isLoadedScene('gresult')) {
			if (!gameResult) {
				gameResult = new gresult.Gresult();
			}
			gameResult.orderFrom = 'gameOver';
			s.msgLayer.addChild(gameResult);
		} else {
			var orderFrom = 'gameOver';
			annie.loadSceneManager('gresult', s.msgLayer, orderFrom);
		}
	});
	/*添加游戏结果页*/
	annie.globalDispatcher.addEventListener('addGameResultPage', function (e) {
		s.msgLayer.removeChildAt(0);
		if (!gameResult) {
			gameResult = new gresult.Gresult();
		}
		gameResult.orderFrom = 'myPrize';
		s.msgLayer.addChild(gameResult);
	});
	/*添加选择奖品页面*/
	annie.globalDispatcher.addEventListener('addChooesGiftBox', function (e) {
		s.msgLayer.removeChildAt(0);
		if (!gameChooesPrize) {
			gameChooesPrize = new gtip.ChooesPrizeBox();
		}
		s.msgLayer.addChild(gameChooesPrize);
	});
	/**/
	annie.globalDispatcher.addEventListener('addWarmTipBox', function (e) {
		s.msgLayer.removeChildAt(0);
		if (!gamePrizeWarmTip) {
			gamePrizeWarmTip = new gtip.WarmTipBox();
		}
		s.msgLayer.addChild(gamePrizeWarmTip);
	});
	/*用选择奖品，提交后提示框*/
	annie.globalDispatcher.addEventListener('addMarkSureTipBox', function (e) {
		s.msgLayer.removeChildAt(0);
		if (!gameUserMakesureTip) {
			gameUserMakesureTip = new gtip.UserMarkSureBox();
		}
		var bringData = e.data;
		if (bringData) {
			gameUserMakesureTip.bringData = bringData;
		}
		s.msgLayer.addChild(gameUserMakesureTip);
	});
	/*我的奖品页*/
	annie.globalDispatcher.addEventListener('addMyPrizePage', function (e) {
		if (annie.isLoadedScene('gmyprize')) {
			if (!gameMyPrize) {
				gameMyPrize = new gmyprize.Gmyprize();
			}
			s.msgLayer.addChild(gameMyPrize);
		} else {
			annie.loadSceneManager('gmyprize', s.msgLayer);
		}
	});
	/*套绳子结束321倒数准备时间*/
	annie.globalDispatcher.addEventListener('readyTime', function (e) {
		// s.msgLayer.removeChildAt(0);
		// if (!gameReadyGo) {
		// 	gameReadyGo = new readyGo.ReadyGo();
		// }
		gameReadyGo.bringData = 'gaming';
		annie.globalDispatcher.dispatchEvent('userAbleToPlayGame');//用户可以继续点击套牛按钮了
		// s.msgLayer.addChild(gameReadyGo);
	});
	annie.globalDispatcher.addEventListener('addTipAlert', function (e) {
		s.tipAlertLayer.removeChildAt(0);
		if (!gameTipAlert) {
			gameTipAlert = new gtipAlert.GtipAlert();
		}
		gameTipAlert.tip_txt.text = e.data;
		s.tipAlertLayer.addChild(gameTipAlert);
	});
	// tipAlertLayer
};
A2xExtend(gameFW.GameFW,annie.Sprite);
